<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:79:"/data/www/html/web2017/public_html/../application/index/view/user/user_reg.html";i:1498806784;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link href="__STATIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <!--<link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">-->
    <!--<link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">-->
    <!--<link href="/static/admin/css/animate.min.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/chosen/chosen.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/switchery/switchery.css" rel="stylesheet">-->
    <!--<link href="/static/admin/css/style.min.css?v=4.1.0" rel="stylesheet">-->
    <!--<link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">-->
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/admin/js/jquery.form.js"></script>
    <script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>
    <script src="/static/pc/js/layer/layer.js"></script>
    <script src="/static/admin/js/laypage/laypage.js"></script>
    <script src="/static/admin/js/laytpl/laytpl.js"></script>
    <!--<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>-->
    <!--<script src="/static/admin/js/content.min.js?v=1.0.0"></script>-->
    <!--<script src="/static/admin/js/plugins/chosen/chosen.jquery.js"></script>-->
    <!--<script src="/static/admin/js/plugins/iCheck/icheck.min.js"></script>-->
    <!--<script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>-->
    <!--<script src="/static/admin/js/plugins/switchery/switchery.js"></script>&lt;!&ndash;IOS开关样式&ndash;&gt;-->
    <!--<script src="/static/admin/js/jquery.form.js"></script>-->
    <!--<script src="/static/admin/js/layer/layer.js"></script>-->
    <!--<script src="/static/admin/js/laypage/laypage.js"></script>-->
    <!--<script src="/static/admin/js/laytpl/laytpl.js"></script>-->
    <!--<script src="/static/admin/js/lunhui.js"></script>-->
    <style>
        .gray-bg{font-family: "Microsoft Yahei"}
        .text{width:100%;height:45px;border:1px #ccc solid;border-radius: 5px;}
        .text1{width:100%;height:45px;border:1px #ccc solid;border-radius: 5px;text-align:center;}
        .p1{font-size:16px;height:18px;color:#000;margin-top:10px;}
        .s1{font-size:16px;color:red;}
        .p2{font-size:18px;height:47px;color:#000; margin:0;}
        .p3{font-size:13px;height:15px;line-hegiht:15px;color:#ccc;padding-left: 3px;}
        .button{font-size:18px;color:#000;width:100%;height:40px;line-height:40px;text-align: center;border-radius: 5px; margin: 0 auto;border:1px #576890 solid;margin-top:50px;}
    </style>

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content bg">
    <form class="form-horizontal m-t" name="add" id="add" method="post" action="<?php echo url('user/user_reg'); ?>">
        <div class="row">

            <div class="col-sm-12" >
                <p class="p1"><span id="xjh">手机号</span></p>
                <p class="p2"><input class="text" type="text" name="mobile"  id="mobile" value="" style="width: 70%;">

                    <input id="yzm" type="button" style="padding:15px 10px;border: 0px; background: #2FAB87;border-radius: 5px;color: #fff;"  onclick="get_code(this);" value="获取验证码" >
                </p>
            </div>

            <div class="col-sm-12" >
                <p class="p1"><span id="xm">验证码</span></p>
                <p class="p2"><input class="text" type="text" name="code" id="code" value=""></p>
            </div>

            <div class="col-sm-12" id="sj" style="display:block;" >
                <p class="p1"><span >登录密码</span></p>
                <p class="p2"><input class="text" type="password" name="password" id="password" value=""></p>
            </div>

            <div class="col-sm-12" id="sj" style="display:block;" >
                <p class="p1"><span >验证密码</span></p>
                <p class="p2"><input class="text" type="password" name="password1" id="password1" value=""></p>
            </div>

            <div class="col-sm-12" >
                <p class="p1"><span>用户昵称</span></p>
                <p class="p2"><input class="text" type="text" name="nickname" id="nickname" value=""></p>
            </div>

            <div class="col-sm-12" >
                        <p class="p1"><span>真实姓名</span></p>
                        <p class="p2"><input class="text" type="text" name="realname" id="realname" value=""></p>
                    </div>



            <div class="col-sm-12" >
                <!--<a href="javascript:;" onclick="reg();"><div class="button">确认</div></a>-->
                <button class="button" type="submit" id="fabu" > 确认 </button>
            </div>

        </div>

</div>
</div>

<script type="text/javascript">
    var countdown=10;

    function settime(val) {
        if (countdown == 0) {
            val.removeAttribute("disabled");
            val.value="获取验证码";
            $('#yzm').css('background',"#2FAB87");
            countdown = 60;
            return false;
        } else {
            val.setAttribute("disabled", true);
            val.value="重新发送(" + countdown + ")";
            $('#yzm').css('background',"#ccc");
            countdown--;
        }
        setTimeout(function() {
            settime(val)
        },1000)
    }


    function get_code(val){
        mobile =  $('#mobile').val();
        if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(mobile))){
            layer.msg('手机号码格式有误',{icon:5,time:1500,shade: 0.1,});
            return false;
        }else{

            $.post('<?php echo url("base/index/get_sms_code"); ?>',
                    {mobile:mobile},
                    function(data){

                        if(data.code==1){
                            settime(val);
                            layer.msg('验证码发送成功，请注意查收',{icon:-1,time:1500,shade: 0.1,});
                        }else{
                            layer.msg('验证码发送失败',{icon:-1,time:2500,shade: 0.1,});
                        }
                    });



        }

    }


    $(function(){
        $('#add').ajaxForm({
            beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
            success: complete, // 这是提交后的方法
            dataType: 'json'
        });

        function checkForm(){

                var password1 =  document.getElementById('password1').value;
                var password =  document.getElementById('password').value;
                var mobile =  document.getElementById('mobile').value;
                var code =  document.getElementById('code').value;
                var nickname =  document.getElementById('nickname').value;
                var realname =  document.getElementById('realname').value;

                if(''==mobile){

                    layer.msg('手机号码不能为空',{icon:5,time:1500,shade: 0.1,});
                    return false;
                }

                if( password==''){
                    layer.msg('密码不能为空',{icon:5,time:1500,shade: 0.1,});
                    return false;
                }

                if( password!=password1){
                    layer.msg('两次输入的密码不同，请确认！',{icon:5,time:1500,shade: 0.1,});
                    return false;
                }

                if(''==code){
                    layer.msg('验证码不能为空',{icon:5,time:1500,shade: 0.1,});
                    return false;
                }

                if(''==nickname){
                    layer.msg('昵称不能为空',{icon:5,time:1500,shade: 0.1,});
                    return false;
                }

 if(''==realname){
                    layer.msg('真实姓名不能为空',{icon:5,time:1500,shade: 0.1,});
                    return false;
                }


        }

        function complete(data){
            if(data.code == 1){
                layer.msg('注册成功',{icon:6,time:1500,shade: 0.1,});


                setTimeout(function() {
                    window.location.href="<?php echo url('index/index'); ?>";
                },1500)
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

    });



//    function reg(){
//
//
//
//
//        $.post('<?php echo url("user/user_reg"); ?>',
//                {code:code,mobile:mobile,password:password,nickname:nickname},
//                function(data){
//                    console.log(data);
//                    if(data.code==1){
//                        layer.msg('注册成功',{icon:6,time:1500,shade: 0.1,});
//
//
//                        setTimeout(function() {
//                            window.location.href="<?php echo url('index/index'); ?>";
//                        },1500)
//
//                    }else{
//                        layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
//                        return false;
//                    }
//                });
//        return false;
//    }



</script>




</body>
</html>